#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <iostream>

using namespace std ;

int main ( )
{
	int sockfd ;
	int len ;
	struct sockaddr_un address ;
	int result ;
	char ch = 'A' ;

	sockfd = socket(AF_UNIX, SOCK_STREAM, 0) ;
	address.sun_family = AF_UNIX ;
	strcpy(address.sun_path, "/tmp/whq/server_socket");
	len = sizeof(address) ;

	result = connect(sockfd, (struct sockaddr *)&address, len);
	if ( result == -1 )
	{
		perror("oops: client1") ;
		exit(1) ;
	}

	string command = "Send T 104" ;
	
	write(sockfd, command.c_str() , command.size() ) ;
	read(sockfd, &ch, 1) ;
	cout<< "Char from server = " << ch << endl ;
	close(sockfd) ;
	
	return 0 ;
}
